<?php
namespace Home\Controller;
use Think\Controller;

class TuiController extends Controller { 
	public function __construct(){
		parent::__construct();
		require_once(I('server.DOCUMENT_ROOT') . '/message/' . 'function.php');
	}   

   public function index(){
   		
   		//dump(PushAllDevices($title='测试推送标题',$content='测试推送内容，测试推送内容，测试推送内容，测试推送内容，',array('jw'=>array('pushCode'=>100,'objectId'=>292,'userId'=>18))));
   		//
   		echo function_exists('fsockopen');
   }


	/**
	 * 推送给1个uid
	 * @param  int $uid     [description]
	 * @param  string $title   [description]
	 * @param  string $content [description]
	 * @param  string $trans   [description]
	 */
	public function pushUid($uid='',$title='',$content='',$trans=''){		
		if($uid){
			$trans=json_decode($trans,true);
			$this->ajaxReturn(PushUid($uid,$title,$content,$trans));
		}
	}

	/**
	 * 推送给多个uid
	 * @param  array $uids     [description]
	 * @param  string $title   [description]
	 * @param  string $content [description]
	 * @param  string $trans   [description]
	 */
	public function pushUidList($uids=array(),$title='',$content='',$trans=''){
		if(!empty($uids)) {
			$trans=json_decode($trans,true);
			$this->ajaxReturn(PushUidList($uids,$title,$content,$trans));
		}	
	}

	/**
	 * 推送给一个频道下的所有用户
	 * @param  int $chid     [description]
	 * @param  string $title   [description]
	 * @param  string $content [description]
	 * @param  string $trans   [description]
	 */
	public function pushChannel($chid,$title='',$content='',$trans=''){
		$trans=json_decode($trans,true);
		$this->ajaxReturn(PushChannel($chid,$title,$content,$trans));
	}

}